<%var jstpl = {%>

    <script>
        var app = new Vue({
            el: "#gexin_body",
            data: {
                data_result: {}
            },
            created: function() {
                this.loadConfig()
            },
            methods: {
                loadConfig: function() {
                    Ajax("/system/config/query", function(d) {
                        if (d != null) {
                            app.data_result = d;
                            for (item in d) {
                                $("input[name='config." + item + "']").val(d[item]);
                                if (item = 'open_reward') {
                                    // form.on('switch(openReward)',function(data){
                                    $("#openRewardCheckbox").prop("checked", d[item] == 1);
                                    // })

                                }
                                if (item = 'open_auto_withdrawal') {
                                    // form.on('switch(openReward)',function(data){
                                    $("#openAutoWithdrawalCheckbox").prop("checked", d[item] == 1);
                                    // })

                                }
                            }
                            let form = layui.form;
                            form.render();
                        }
                    })
                }
            },
            mounted: function() {
                var form = layui.form;
                //监听提交
                form.on('submit(formDemo)', function(data) {
                    Ajax("/system/config/addOrUpd", data.field, function(d) {
                        if (d.state == true) {
                            gx.alerts("保存成功！", function() {
                                layer.closeAll();
                                app.loadConfig();
                            })
                        } else {
                            gx.alert(d.msg)
                        }
                    })
                });
                form.on('switch(openReward)', function(data) {
                    console.log(this.click);
                    $("#openRewardId").val(this.checked ? 1 : 0);
                })


                form.on('switch(openAutoWithdrawal)', function(data) {
                    console.log(this.click);
                    $("#openAutoWithdrawalId").val(this.checked ? 1 : 0);
                })

            }
        })
    </script>

    <%};%>

        <%var csstpl = {%>

            <%};%>

                <%var title={%>系统配置
                    <%};%>
                        <%layout("../layout/_layout_layui.html",{title:title,jstpl:jstpl,csstpl:csstpl}){ %>
                            <section id="content">
                                <form class="layui-form form-horizontal">
                                    <div class="layui-row">
                                        <div class="layui-col-md12">
                                            <div class="layui-form" wid100="">

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">应用名称</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" name="config.host_name" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">管理后台标题</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" name="config.sys_title" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">系统介绍</label>
                                                    <div class="layui-input-block">
                                                        <textarea style="height: 80px;" type="text" name="config.sys_desc" class="layui-input">${config.sys_desc!}</textarea>
                                                    </div>
                                                </div>


                                                <input type="hidden" name="config.id" lay-verify="" class="layui-input">
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">应用访问地址</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" name="config.host_address" lay-verify="" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">网站版权</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" name="config.host_copy_right" lay-verify="" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">后端资源版本号</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="config.static_admin_ver" lay-verify="number" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">web版本号</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" name="config.static_web_ver" lay-verify="number" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">静态资源Cdn域名</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" name="config.static_cdn_host" lay-verify="" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">配置签到积分</label>
                                                    <div class="layui-input-block">
                                                        <input type="text" name="config.sign_in_integral" lay-verify="number" class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">用户转发下单奖励</label>
                                                    <div class="layui-input-block">
                                                        <input type="hidden" id="openRewardId" name="config.open_reward">
                                                        <input type="checkbox" id="openRewardCheckbox" lay-filter="openReward" lay-skin="switch" lay-text="开启|关闭">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">自动提现</label>
                                                    <div class="layui-input-block">
                                                        <input type="hidden" id="openAutoWithdrawalId" name="config.open_auto_withdrawal">
                                                        <input type="checkbox" id="openAutoWithdrawalCheckbox" lay-filter="openAutoWithdrawal" lay-skin="switch" lay-text="开启|关闭">
                                                    </div>
                                                </div>

                                                <div class="layui-form-item">
                                                    <div class="layui-input-block">
                                                        <button type="button" class="layui-btn" lay-submit="" lay-filter="formDemo">确认保存</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </section>

                            <%}%>